﻿
@{
    ViewBag.Title = "添加博客";
}

<link href="~/Content/CSS/animate.css" rel="stylesheet" />
<link href="~/Content/lib/wangEditor/dist/css/wangEditor.css" rel="stylesheet" />
<link href="~/Content/CSS/blogArticleStyle.css" rel="stylesheet" />
<script src="~/Content/lib/wangEditor/dist/js/wangEditor.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script type="text/javascript">
    $(function () {
        // 获取元素
        var textarea = document.getElementById('bcontent');
        // 生成编辑器
        var editor = new wangEditor(textarea);
        // 自定义菜单
        editor.config.menus = [
        'source',
        '|',
        'bold',
        'underline',
        'italic',
        'eraser',
        'forecolor',
        'bgcolor',
        '|',
        'quote',
        'fontfamily',
        'fontsize',
        'head',
        'unorderlist',
        'orderlist',
        'alignleft',
        'aligncenter',
        'alignright',
        '|',
        'link',
        'unlink',
        'emotion',
        '|',
        'img',
        'insertcode',
        '|',
        'undo',
        'redo',
        'fullscreen'
        ];
        // 上传图片（举例）
        editor.config.uploadImgUrl = '/admin/BlogArticle/upload';
        editor.config.uploadImgFileName = 'imgFile'
        editor.create();
    });
    //添加博文之后
    function afterAddBlog(data) {
        var serverData = data.split(':');
        if (serverData[0] == "ok")
        {
            alert(serverData[1]);
            window.location.reload();
        }
    };
</script>
<div class="blogcontent">
    <!-- head star -->
    <div class="tnav row border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <h2 class="fl">博客后台</h2>
            <ol class="breadcrumb fl">
                <li><a href="/admin/Home">博客管理</a></li>
                <li><strong>发布博客</strong></li>
            </ol>
        </div>
    </div>
    <!-- head end -->
    <!-- form star -->
    <div class="">
        <div class="wrapper wrapper-content animated fadeInUp" style="height:600px;padding-bottom:30px;overflow:auto">
            @using (Ajax.BeginForm("Add", "BlogArticle", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterAddBlog" }, new { @class = "form-horizontal" }))
            {
                <div class="form-group">
                    <label class="col-md-1 control-label">标题&nbsp;:</label>
                    <div class="col-md-11">
                        <input type='text' name='btitle' id='title' value='' class='form-control' placeholder='' />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">类别&nbsp;:</label>
                    <div class='col-md-2'>
                        <select name='bcategory' id='original' class='form-control'>
                            <option value='技术博文' selected='selected'>技术博文</option>
                            <option value='随笔日志'>随笔日志</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-1 control-label">内容&nbsp;:</label>
                    <div class='col-md-11'>
                        <textarea id="bcontent" rows="18" name="bcontent" class='form-control'>
                            <p>请输入内容...</p>
                        </textarea>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-1 col-md-10">
                        <input type='submit' id='submit' class='btn btn-info' value='保存' data-loading='稍候...' />
                    </div>
                </div>

            }
        </div>
    </div>
    <!-- form end -->
</div>



